package com.zack.gank.gankandroid.main.main;

import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.design.widget.TabLayout;
import android.support.v4.app.Fragment;
import android.support.v4.view.ViewPager;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.orhanobut.logger.Logger;
import com.zack.gank.gankandroid.gankandroid.R;
import com.zack.gank.gankandroid.main.find.IosFindFragment;
import com.zack.gank.gankandroid.main.find.JavaFindFragment;
import com.zack.gank.gankandroid.main.find.adapter.FindAdapter;
import com.zack.gank.gankandroid.main.BaseFragment;
import com.zack.gank.gankandroid.main.find.AndroidFindFragment;
import com.zack.gank.gankandroid.main.find.SelectFindFragment;

import java.util.ArrayList;

/**
 * Created by Android on 2017/7/12.
 */
public class FindFragment extends BaseFragment {

    TabLayout tabFind;
    ViewPager vpFind;
    private ArrayList<Fragment> fragmentList;
    private ArrayList<String> tabTitle=new ArrayList<>();
    public FindFragment() {
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.fg_find, container,false);
        tabFind= (TabLayout) view.findViewById(R.id.tab_find);
        vpFind= (ViewPager) view.findViewById(R.id.vp_find);
        inintView();
        return view;
    }


    private void inintView(){
        fragmentList=new ArrayList<Fragment>();
        fragmentList.add(new SelectFindFragment());
        fragmentList.add(new AndroidFindFragment());
        fragmentList.add(new IosFindFragment());
        fragmentList.add(new JavaFindFragment());

        tabTitle.add("精选");
        tabTitle.add("Android");
        tabTitle.add("ios");
        tabTitle.add("前端");
//        tabTitle.add("拓展资源");
//        tabTitle.add("福利");
//        tabTitle.add("休息视频");
        vpFind.setAdapter(new FindAdapter(getChildFragmentManager(),fragmentList,tabTitle));
        tabFind.setupWithViewPager(vpFind);
        Logger.v("findfragment");
    }


}
